import { API } from '@/services/model/baseModel';
import { LoginParamModel } from '@/services/model/loginModel';
import config from '@/utils/config';
import { request } from '@/utils/http';

/**
 * 发送验证码
 * @returns '成功'
 */
const sendCode = (mobile: String) => {
  return request.post<API<string>>(config.url.send_code, { mobile: mobile });
};

/**
 * 校验验证码
 * @returns '成功'
 */
const validateCode = (mobile: String, code: String) => {
  return request.post<API<string>>(config.url.validate_code, { mobile: mobile, code: code });
};

/**
 * 重置密码
 * @returns '成功'
 */
const reset = (param: LoginParamModel) => {
  return request.post<API<string>>(config.url.reset_pwd, param);
};

/**
 * 注册
 * @returns '成功'
 */
const register = (param: LoginParamModel) => {
  return request.post<API<string>>(config.url.register_user, param);
};

/**
 * 更换手机
 * @returns '成功'
 */
const replaceMobile = (param: LoginParamModel) => {
  return request.post<API<string>>(config.url.relpace_mobile, param);
};

export { sendCode, reset, register, validateCode, replaceMobile };
